
try:
    f1 = open("test.py", "r",encoding="utf-8")
    f2 = open("test1.py","w",encoding="utf-8")
    fileLines = f1.readlines()
    row = 0
    while row < len(fileLines):
        if fileLines[row][0] == "#":
            print("There are", row + 1, "of lines have character #.")
        print(fileLines[row].strip("\n"))
        f2.write(fileLines[row])
        row += 1
        f1.close()
    f2.close()  # close放到else里面
except:         # error类型不对应报系统错误
    print("file cannot be found")
# else:

finally:
    print("End of reading file")